/*
 * sprite.h
 *
 *  Created on: 2010/05/20
 *      Author: angela
 */

#ifndef SPRITE_H_
#define SPRITE_H_


/** @defgroup Sprite Sprite
 * @{
 *
 * Sprite related functions
 */

/** A Sprite is an "object" that contains all needed information to
 * create, animate, and destroy a pixmap.  The functions assume that
 * the background is BLACK and they take into account collision with
 * other graphical objects or the screen limits.
 */
typedef struct {
  int x, y;            ///< current sprite position
  int width, height;   ///< sprite dimensions
  char * map;           ///< the sprite pixmap (use read_xpm())
} Sprite;

/** Reads a xpm-like sprite defined in "map" (look at pixmap.h for
 * examples). Returns the address of the allocated memory where the
 * sprite was read. Updates "width" and "heigh" with the sprite
 * dimension.  Return NULL on error.
 * Assumes that VRES and HRES (the screen vertical and horizontal resolution)
 * are externaly defined.
 *
 * Usage example, using the defined sprite in pixmap.h:
 * <pre>
 *   #include "pixmap.h" // defines  pic1, pic2, etc
 *   int wd, hg;memory whose address
 *   char *sprite = read_xpm(pic1, &wd, &hg);
 * </pre>
*/
char * read_xpm(char * map[], int * wd, int * ht);

/** Creates with random speeds (not zero) and position
 * (within the screen limits), a new sprite with pixmap "pic", in
 *  is "base".
 * Returns NULL on invalid pixmap.
 */
Sprite * create_sprite(char * pic[], char * base);

/** Draw a Sprite.
 *  @param sprt Sprite.
 *  @param base Memory address.
 */
void draw_sprite(Sprite * sprt, char * base);

#endif /* SPRITE_H_ */
